package academic.emailClient.security.persistence;

import java.util.ArrayList;
import java.util.HashMap;

import academic.emailClient.security.model.User;
/**
 * 
 * @author pc
 *
 */
public class UserDAOMock implements UserDAO{
	
	private HashMap<String, User> userList;	
	
	/**
	 * Constructor
	 */
	public UserDAOMock() {
		userList = new HashMap<String, User>();
		userList.put("asanchezb", new User("aleja@sanchez.com", "Alejandra Sanchez", "asanchezb",  "asanchezb"));
		userList.put("loulou", new User("loujaine@jaafouri.com", "Loojaine Jaafouri", "loulou", "loulou"));
		userList.put("oualid", new User("oualid@elhalimi.com", "Oualid El Halimi", "oualid", "oualid"));
		userList.put("pratik", new User("pratik@joshi.com", "Pratik Joshi", "pratik", "pratik"));
		userList.put("ravi", new User("ravi@patel.com", "Ravikumar Patel", "ravi", "ravi"));		
	}

	@Override
	public User load(User user){
		if (userList.containsKey(user.getUsername()))
			return userList.get(user.getUsername());
		return null;
	}

	@Override
	public ArrayList<User> load() {
		return new ArrayList<User>(userList.values());
	}

	@Override
	public User getUser(String emailAccount) {
		for (User user : userList.values()){
			if (user.getEmail().equals(emailAccount))
				return user;
		}
		return null;
	}

	@Override
	public User getUserByFullName(String fullName) {
		for (User user : userList.values()){
			if (user.getFullname().equals(fullName))
				return user;
		}
		return null;
	}
	

}
